package com.whut.v_model;

import java.text.DecimalFormat;

/**
* 不同种类的参建单位的排序统计用的model
* @author fuzhenjie
* @date 19.7.27 21:21
*/
public class UnitRankStatistics {
    private String unitName;
    private Float point1;
    private Float point2;
    private String tendency;

    public UnitRankStatistics(String unitName, Float point1, Float point2, String tendency) {
        this.unitName = unitName;
        this.point1 = point1;
        this.point2 = point2;
        this.tendency = tendency;
    }

    public UnitRankStatistics() {
    }

    public String getUnitName() {
        return unitName;
    }

    public void setUnitName(String unitName) {
        this.unitName = unitName;
    }

    public Float getPoint1() {
        return point1;
    }

    public void setPoint1(Float point1) {
        this.point1 = point1;
    }

    public Float getPoint2() {
        return point2;
    }

    public void setPoint2(Float point2) {
        /*float price=1.2;
        String p=decimalFomat.format(price);//format 返回的是字符串*/
        //构造方法的字符格式这里如果小数不足2位,会以0补足.
        if(point2 != null){
            DecimalFormat decimalFormat=new DecimalFormat(".00");
            System.out.println(point2);
            String p = decimalFormat.format(point2);
            this.point2 = Float.parseFloat(p);
        }else {
            this.point2 = point2;
        }

    }

    public String getTendency() {
        return tendency;
    }

    public void setTendency() {
        if(point1 == null || point2 == null){
            tendency = "-";
        }else if(point2.equals(point1)){
            tendency = "=";
        }else {
            tendency = point1>point2?"d":"u";
        }
    }
}
